package code.snippet.demo

import code.snippet.LiftComponentSnippet
import bs.{HForm, Button, Modal, Accordion}
import code.model.Member
import net.liftweb.http.SHtml
import scala.xml.NodeSeq

object ModalDemo extends LiftComponentSnippet[Modal] {
  override val component = Modal(
    title = "登录",
    body = HForm(
      "邮箱" -> SHtml.text("", _ => {}, "id" -> "email"),
      "密码" -> SHtml.password("", _ => {}, "id" -> "password")
    ).render,
    submitter = Button("确定").render
  )

  override def render: (NodeSeq) => NodeSeq = {_=>
    val modal = component.render
    val modalId = s"#${(modal.head \ "@id").text}"
    modal ++ Button("显示Modal").transformer.apply(<a href={modalId} data-toggle="modal"></a>)
  }
}
